<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table{
            border-collapse: collapse;
            margin: 20px auto;
        }
        tr{
            height: fit-content;
        }
        td{
            width: 100px;
            height: 50px;
            border: 1px solid red;
        }
    </style>
</head>
<body>
    <input type="text" placeholder="行" id="col">
    <input type="text" placeholder="列" id="row">
    <button id="btn">生成</button>
    <table id="tab">
     
    </table>
    <script>
        // 生成任意表格
        
        var btn = document.getElementById('btn')
        var col = document.getElementById('col')
        var row = document.getElementById('row')
        var tab = document.getElementById('tab')
        
        btn.onclick = function () {
            var str = ''
            var a = Number(col.value)
            var b = Number(row.value)
            for (var i = 0 ; i < a ; i++) {
                str += '<tr>';
                for(var j = 0 ; j < b; j++){
                    str += '<td></td>';
                }
                str += '</tr>';
            }
            tab.innerHTML += str
        }
        
    </script>
</body>
</html>